	<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<body>
<script type="text/javascript" src="/${initParam.context_root}/script/pscript5.js"></script>
<script type="text/javascript">

var cpu = ${requestScope.completePCDetailPrice.CPUPRICE};
var mainboard = ${requestScope.completePCDetailPrice.MAINBOARDPRICE};
var cooler = ${requestScope.completePCDetailPrice.COOLERPRICE};
var memory = ${requestScope.completePCDetailPrice.MEMORYPRICE};
var graphic = ${requestScope.completePCDetailPrice.GRAPHICPRICE};
var hdd = ${requestScope.completePCDetailPrice.HDDPRICE};
var ssd = ${requestScope.completePCDetailPrice.SSDPRICE };
var dvd = ${requestScope.completePCDetailPrice.DVDPRICE};
var sound = ${requestScope.completePCDetailPrice.SOUNDPRICE};
var power = ${requestScope.completePCDetailPrice.POWERPRICE};
var kase = ${requestScope.completePCDetailPrice.CASEPRICE};
var os = ${requestScope.completePCDetailPrice.OSPRICE};
var keyboard = 0;
var moniter = 0;
var mouse = 0;
var sum = 0;

$(document).ready(function(){	

sum = cpu+mainboard+cooler+memory+graphic+hdd+ssd+dvd+sound+power+kase+os;
$("#completePrice").val(sum);

	$(".product").on("change", function(){
		var id = $(this).val();
		var txt = this.options[this.selectedIndex].text;
		$.getJSON("/droowa/product/getProductInfo.do", {"id":id,"sort":txt}, callback);
	});
});

function callback(data){
	if(data.category=='CPU'){
		cpu = data.price;
		$("#cpu").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='마우스'){
		mouse = data.price;
		
	}else if(data.category=='파워'){
		power = data.price;
		$("#power").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='키보드'){
		keyboard = data.price;
		
	}else if(data.category=='케이스'){
		kase = data.price;
		$("#case").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='모니터'){
		moniter = data.price;
		
	}else if(data.category=='메인보드'){
		mainboard = data.price;
		$("#mainboard").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='쿨러'){
		cooler = data.price;
		$("#cooler").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='RAM'){
		memory = data.price;
		$("#memory").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='그래픽카드'){
		graphic = data.price;
		$("#graphic").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='HDD'){
		hdd = data.price;
		$("#hdd").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='SSD'){
		ssd = data.price;
		$("#ssd").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='DVD'){
		dvd = data.price;
		$("#dvd").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='사운드카드'){
		sound = data.price;
		$("#sound").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='운영체제'){
		os = data.price;
		$("#os").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}else if(data.category=='메모리'){
		memory = data.price;
		$("#memory").html(data.name);
		if(data.fileName==null){
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/No_image.jpg'>");
		}else{
			$("#picture").html("<img height='244px' width='244px' src='/droowa/product-img/"+data.fileName+"'>");
		}
	}
	
	sum = cpu+mainboard+cooler+memory+graphic+hdd+ssd+dvd+sound+power+kase+os;
	$("#completePrice").val(sum);
}

function getProductId(data){
	$(data).parent().next().html(data.value);
}

$(document).ready(function(){
	$("#reset").on("click", function(){
		$("#mainboard").html("");
		$("#cpu").html("");
		$("#cooler").html("");
		$("#memory").html("");
		$("#graphic").html("");
		$("#hdd").html("");
		$("#ssd").html("");
		$("#dvd").html("");
		$("#sound").html("");
		$("#power").html("");
		$("#case").html("");
		$("#os").html("");
	});
});
</script>
<h2 align="center">컴퓨터수정</h2>
<form action="/droowa/product/updateCompletePC.do" onsubmit="return chk(this)" method="post" encType="multipart/form-data">
<input type="hidden" name="completeId" value="${requestScope.completePC[0].COMPLETEID}">
<input type="hidden" name="picture" value="${requestScope.completePC[0].FILENAME}">
<table align="center" border="1" style="border-collapse: collapse;">
	<tr>
		<td align="center" colspan="2" height="90">
			<c:choose>
				<c:when test="${requestScope.completePC[0].FILENAME!=null }">
					<img src="/droowa/product-img/${requestScope.completePC[0].FILENAME}" style="width:90px; height=90px;">
				</c:when>
				<c:when test="${requestScope.completePC[0].FILENAME==null}">
					<img src="/droowa/product-img/No_image.jpg" style="width:90px; height=90px;">
				</c:when>	
			</c:choose>
		</td>
	</tr>
	<tr align="center">
		<td bgcolor="#BDBDBD">컴퓨터명</td>
		<td width="200">
			<input type="text" name="completeName" id="completeName" value="${requestScope.completePC[0].COMPLETENAME}" style="width:200px;">
		</td>
	</tr>
	<tr align="center">
		<td bgcolor="#BDBDBD">가격</td>
		<td>
			<input type="text" name="completePrice" id="completePrice" value="${requestScope.completePC[0].COMPLETEPRICE}" style="width:200px;">
		</td>
	</tr>
	<tr align="center">
		<td bgcolor="#BDBDBD">수량</td>
		<td>
			<input type="text" name="completeQuantity" id="completeQuantity" value="${requestScope.completePC[0].COMPLETEQUANTITY}" style="width:200px;">
		</td>
	</tr>
	<tr>
		<td>
			<select id="mainboardId" name="mainboardId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.mainboardId}'>메인보드</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='메인보드'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="mainboard">
			${requestScope.completePC[0].MAINBOARDNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="cpuId" name="cpuId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.cpuId}'>CPU</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='CPU'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="cpu">
			${requestScope.completePC[0].CPUNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="coolerId" name="coolerId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.coolerId}'>쿨러</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='쿨러'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="cooler">
			${requestScope.completePC[0].COOLERNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="memoryId" name="memoryId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.memoryId}'>RAM</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='RAM'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="memory">
			${requestScope.completePC[0].MEMORYNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="graphicId" name="graphicId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.graphicId}'>그래픽카드</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='그래픽카드'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="graphic">
			${requestScope.completePC[0].GRAPHICNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="hddId" name="hddId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.hddId}'>HDD</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='HDD'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="hdd">
			${requestScope.completePC[0].HDDNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="ssdId" name="ssdId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.ssdId}'>SSD</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='SSD'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="ssd">
			${requestScope.completePC[0].SSDNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="dvdId" name="dvdId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.dvdId}'>DVD</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='DVD'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="dvd">
			${requestScope.completePC[0].DVDNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="soundId" name="soundId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.soundId}'>사운드카드</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='사운드카드'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="sound">
			${requestScope.completePC[0].SOUNDNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="powerId" name="powerId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.powerId}'>파워</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='파워'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="power">
			${requestScope.completePC[0].POWERNAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="caseId" name="caseId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.caseId}'>케이스</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='케이스'}">	
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="case">
			${requestScope.completePC[0].CASENAME}
		</td>
	</tr>
	<tr>
		<td>
			<select id="osId" name="osId" class="product" onchange="getProductId(this)" style="width:200px;">
				<option value='${requestScope.complete.osId}'>OS</option>
				<c:forEach items="${requestScope.product_list}" var="product">
					<c:choose>
						<c:when test="${product.categoryName=='운영체제'}">
							<option value="${product.id}">
								${product.name}
							</option>
						</c:when>
					</c:choose>
				</c:forEach>
			</select>
		</td>
		<td align="center" id="os">
			${requestScope.completePC[0].OSNAME}
		</td>
	</tr>
</table>
<table align="center">
	<tr>
		<td align="center">사진 업로드</td>
		<td>
			<input type="file" name="pic">
		</td>
	</tr>
</table>
<table align="center">
	<tr>
		<td width="285"></td>
		<td>
			<input type="hidden" value="false" name="event">
			<input type="reset" value="초기화" id="reset">
			<input type="submit" value="수정" style="width:60px;">		
		</td>
	</tr>
</table>
</form>
</body>
